// app.js




App({

  onLaunch() {
    const windowInfo = wx.getWindowInfo();
    const appBaseInfo = wx.getAppBaseInfo();
    const deviceInfo = wx.getDeviceInfo();
    var isIos = deviceInfo.system.indexOf('iOS') > -1;
    this.globalData.statusHeight = windowInfo.statusBarHeight;
    this.globalData.navHeight = isIos ? 44 : 48;
    this.globalData.fontSize = appBaseInfo.fontSizeSetting;
    //设置低版本不显示自定义导航栏
    if (appBaseInfo.SDKVersion && appBaseInfo.SDKVersion.split('.')[0] * 1 <= 2 && appBaseInfo.SDKVersion.split('.')[1] * 1 < 5) {
      this.globalData.navHeightHidden = true;
    }
    console.log("statusHeight:" + this.globalData.statusHeight +
      " navHeight:" + this.globalData.navHeight +
      " fontSize:" + this.globalData.fontSize +
      " navHeightHidden:" + this.globalData.navHeightHidden);
    const token = wx.getStorageSync('accessToken');
    if (!token) {
      //打开小程序时都会去自动登录
      wx.clearStorageSync('autoLogin');
      wx.redirectTo({
        url: '/pages/login/login'
      })
      return;
    }
  },
  globalData: {
    interval: "",
    //自定义导航组件高度
    navHeightHidden: false,
    statusHeight: null,
    navHeight: null,
    fontSize: null,
  },
  addPerson() {
    // wx.onAppRoute(function (res) {
    //   console.log('route', res)
    //   let pages = getCurrentPages()
    //   let view = pages[pages.length - 1]
    //   if (view) {
    //     wx.showShareMenu({
    //       withShareTicket: true,
    //       menus: ['shareAppMessage'],
    //       complete: function () {
    //         console.log("分享成功")
    //       }
    //     })
    //   }
    // })

  },

})